import { request } from '@umijs/max';

// 从后台获取所有icon
export async function queryAllIcon(): Promise<{
  status: string;
  data: any[] }> {
  return request('/api/setting/allIcon');
}

// 1，家庭成员获取
export async function queryFamily(): Promise<{
  status: string;
  data: any[] }> {
  return request('/api/setting/family');
}

// 1.1，家庭成员修改
export async function updateFamily(data: Record<string, any>, options?: Record<string, any>) {
  return request('/api/setting/family', {
    data,
    method: 'PUT',
    ...(options || {}),
  });
}

// 1.2，家庭成员修改
export async function addFamily(data: Record<string, any>, options?: Record<string, any>) {
  return request('/api/setting/family', {
    data,
    method: 'POST',
    ...(options || {}),
  });
}

// 1.3，删除家庭成员
export async function deleteFamily(data: { key: string }, options?: Record<string, any>) {
  return request<Record<string, any>>('/api/setting/family', {
    data,
    method: 'DELETE',
    ...(options || {}),
  });
}

// 2，收入类型获取
export async function queryIncome(): Promise<{
  status: string;
  data: any[] }> {
  return request('/api/setting/income');
}

// 2.1，收入类型修改
export async function updateIncome(data: Record<string, any>, options?: Record<string, any>) {
  return request('/api/setting/income', {
    data,
    method: 'PUT',
    ...(options || {}),
  });
}

// 2.2，收入类型修改
export async function addIncome(data: Record<string, any>, options?: Record<string, any>) {
  return request('/api/setting/income', {
    data,
    method: 'POST',
    ...(options || {}),
  });
}

// 2.3，删除收入类型
export async function deleteIncome(data: { key: string }, options?: Record<string, any>) {
  return request<Record<string, any>>('/api/setting/income', {
    data,
    method: 'DELETE',
    ...(options || {}),
  });
}

// 3，支出类型获取
export async function queryPayment(): Promise<{
  status: string;
  data: any[] }> {
  return request('/api/setting/payment');
}

// 3.1，支出类型修改
export async function updatePayment(data: Record<string, any>, options?: Record<string, any>) {
  return request('/api/setting/payment', {
    data,
    method: 'PUT',
    ...(options || {}),
  });
}

// 3.2，支出类型修改
export async function addPayment(data: Record<string, any>, options?: Record<string, any>) {
  return request('/api/setting/payment', {
    data,
    method: 'POST',
    ...(options || {}),
  });
}

// 3.3，删除支出类型
export async function deletePayment(data: { key: string }, options?: Record<string, any>) {
  return request<Record<string, any>>('/api/setting/payment', {
    data,
    method: 'DELETE',
    ...(options || {}),
  });
}

